//
//  DUVideoCoverViewCell.m
//  APP
//
//  Created by duyujin1 on 2021/8/13.
//

#import "DUVideoCoverViewCell.h"
#import "Masonry.h"
#import "DUVideoPlayer.h"

@interface DUVideoCoverViewCell()
@property (nonatomic,strong)UIImageView * playButton;

@property (nonatomic,strong)UIView * titleView;
//@property (nonatomic,strong)UILabel * titleLabel;
@end

@implementation DUVideoCoverViewCell
-(instancetype)initWithFrame:(CGRect)frame{
    if(self=[super initWithFrame:frame]){
        self.layer.shadowOffset = CGSizeMake(0, 0);
        self.layer.shadowColor = [UIColor blackColor].CGColor;
        self.layer.shadowOpacity = 0.6;
        self.layer.shadowRadius = 10;
        self.layer.masksToBounds=NO;
        [self addSubview:self.coverView];
        [self addSubview:self.titleView];
        [self.coverView addSubview:self.playButton];
        [self.titleView addSubview:self.titleLabel];
        
        [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.mas_equalTo(self);
            make.bottom.mas_equalTo(self).offset(-DUVideoToolbarHeight);
        }];
        [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self.coverView);
            make.height.mas_equalTo(50);
            make.width.mas_equalTo(50);
        }];
        [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.coverView.mas_bottom);
            make.left.right.mas_equalTo(self.coverView);
            make.height.mas_equalTo(DUVideoToolbarHeight);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.titleView);
            make.left.mas_equalTo(self.titleView).offset(10);
        }];
    }
    return self;
}

-(UIImageView *)coverView{
    if(!_coverView){
        _coverView=[[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _coverView;
}

-(UIImageView *)playButton{
    if(!_playButton){
        _playButton=[[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _playButton;
}

-(UIView *)titleView{
    if(!_titleView){
        _titleView=[[UIView alloc] initWithFrame:CGRectZero];
        _titleView.backgroundColor=[UIColor whiteColor];
    }
    return _titleView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel=[[UILabel alloc] initWithFrame:CGRectZero];
        //_titleLabel.text=@"Big Buck Bunny";
        _titleLabel.textColor=[UIColor blackColor];
        _titleLabel.font=[UIFont systemFontOfSize:20];
    }
    return _titleLabel;
}

#pragma mark -public method

-(void)layoutWithVideoCoverUrl:(NSString *)videoCoverUrl videoUrl:(NSString *)videoUrl{
    _coverView.image=[UIImage imageNamed:videoCoverUrl];
    _playButton.image=[UIImage imageNamed:@"videoPlay"];
    _videoUrl=videoUrl;
}

#pragma mark -private method


@end
